const express = require('express')
const path = require('path')
//创建服务器
const app = express()
// 处理跨域问题
const cors = require('cors')
app.use(cors())
//处理json数据，不然无法读取会显示undefined
app.use(express.json())
//创建路由
require('./routes/admin/index')(app)
//连接数据库
require('./plugins/db')()
require('./routes/web/index')(app)
app.set('psw', 'dadsadada')
//设置静态资源可以被访问
app.use('/uploads', express.static(path.join(__dirname, 'uploads')))
app.listen(3000, () => {
  console.log('server is running');

})